package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bean.DbBean;
import bean.userBean;

/**
 * Servlet implementation class userInfosvl
 */
@WebServlet("/userInfosvl")
public class userInfosvl extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public userInfosvl() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		DbBean db = new DbBean();
		request.setCharacterEncoding("utf-8");
		HttpSession session = request.getSession();
		//System.out.println("kkkkkkkkkkkkkkkkkkkkk");
		int id = (int)session.getAttribute("userId");
//		String id = (String)session.getAttribute("userId");
//		if(id.equals(null)) {
//			response.sendRedirect("login.jsp");
//		}
		//System.out.println("aaaaaaaaaaaaa");
		//System.out.print(id);
		userBean ub = new userBean();
		ArrayList list = new ArrayList();
		list = ub.selectUserInfo(id);
		session.setAttribute("user", list);
		response.sendRedirect("editUser.jsp");
	}

	}


